package com.da.javatest.niuke.jianzhi;

/**
 * @author chenlida
 * @date 2020/10/23 15:38
 * https://www.nowcoder.com/practice/3194a4f4cf814f63919d0790578d51f3?
 * tpId=13&tags=&title=&diffculty=0&judgeStatus=0&rp=1
 */
public class C44Solution {
    public static String ReverseSentence(String str) {
        StringBuilder data = new StringBuilder();
        String[] s = str.split(" ", -1);
        for (int i = s.length - 1; i >= 0; i--) {
            data.append(s[i]);
            if (i != 0) {
                data.append(" ");
            }
        }
        return data.toString();
    }

    public static void main(String[] args) {
        System.out.println(ReverseSentence("student. a am I"));
        System.out.println(ReverseSentence("    "));
    }
}
